package system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import common.controller.base.BaseController;
import common.model.po.SysUpdateLog;
import common.model.request.base.PaginationRequest;
import common.model.response.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import system.model.request.SearchUpdateLogRequest;
import system.model.request.SaveUpdateLogRequest;
import system.service.SysUpdateLogService;

import javax.annotation.Resource;

/**
 * 更新日志管理
 *
 * @author 米泽鹏
 * @since 2024-01-13 下午 07:21
 */
@Api(tags = "更新日志管理")
@RestController
@RequestMapping("/system/sys-update-log")
public class SysUpdateLogController extends BaseController {

	@Resource
	private SysUpdateLogService updateLogService;

	@ApiOperation(value = "更新日志分页查询", notes = "更新日志分页查询")
	@PostMapping("/readOnly/pageUpdateLog")
	public Result<Page<SysUpdateLog>> pageUpdateLog(@ApiParam(value = "更新日志分页查询请求", required = true) @RequestBody @Validated PaginationRequest<SearchUpdateLogRequest, SysUpdateLog> paginationRequest) {
		return successWithData(updateLogService.pageUpdateLog(paginationRequest));
	}

	@ApiOperation(value = "更新日志新增或更新", notes = "更新日志新增或更新")
	@PostMapping("/saveUpdateLog")
	public Result<?> saveUpdateLog(@ApiParam(value = "更新日志新增或更新请求", required = true) @RequestBody @Validated SaveUpdateLogRequest request) {
		return updateLogService.saveUpdateLog(request);
	}

	@ApiOperation(value = "更新日志删除", notes = "更新日志删除")
	@DeleteMapping("/deleteUpdateLog/{id}")
	public Result<?> deleteUpdateLog(@ApiParam(value = "更新日志id", required = true) @PathVariable Long id) {
		return updateLogService.deleteUpdateLog(id);
	}

}
